# Contributor: Henrik Riomar <henrik.riomar@gmail.com>
# Maintainer:
pkgname=tpm2-pkcs11
pkgver=1.9.0
pkgrel=1
pkgdesc="A PKCS#11 interface for TPM2 hardware"
url="https://github.com/tpm2-software/tpm2-pkcs11"
arch="all !armhf !armv7 !riscv64 !x86" # blocked by py3-tpm2-pytss
license="BSD-2-Clause"
depends="
	bash
	py3-asn1-modules
	py3-cryptography
	py3-tpm2-pytss
	py3-yaml
	python3
	tpm2-tools
	"
makedepends="
	autoconf
	autoconf-archive
	automake
	libtool
	linux-headers
	openssl-dev
	py3-setuptools
	python3-dev
	sqlite-dev
	tpm2-abrmd-dev
	tpm2-tss-dev
	yaml-dev
	"
options="!check"  # Requires IBM TPM simulator
subpackages="$pkgname-dev $pkgname-pyc"
source="$pkgname-$pkgver.tar.gz::https://github.com/tpm2-software/tpm2-pkcs11/archive/$pkgver.tar.gz"

prepare() {
	default_prepare
	sed -i '/git describe/d' bootstrap
	echo "$pkgver" > VERSION
	./bootstrap
}

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--target="$CTARGET" \
		--prefix=/usr
	make
	cd tools && python3 setup.py build
}

package() {
	make DESTDIR="$pkgdir" install
	cd tools && python3 setup.py install --skip-build --root="$pkgdir"
}

sha512sums="
711f6608c30013b549e810e457728c36944a108866b975b2725d99893c747fcd3f74cfdb977b0b59d00fd5d72d92ba6a28f6b014dfa76a10cdbfd3f7c9289694  tpm2-pkcs11-1.9.0.tar.gz
"
